package com.apchernykh.rozhlasapp;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.util.AttributeSet;
import android.widget.Checkable;
import android.widget.TextView;

public class CheckableTextView extends TextView implements Checkable
{
    private boolean mChecked;

    public CheckableTextView(Context iContext) {
        super(iContext);
    }

    public CheckableTextView(Context iContext, AttributeSet iAttributeSet) {
        super(iContext, iAttributeSet);
    }

    @SuppressWarnings("deprecation")
	public void setChecked(boolean iChecked) {
        mChecked = iChecked;
        setBackgroundDrawable(iChecked ? new ColorDrawable(0x40000040) : null);
    }

    public boolean isChecked() {
        return mChecked;
    }

    public void toggle() {
        setChecked(!mChecked);
    }
}